package com.komon.parser;

import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.util.regex.Pattern;

public class InternalReader implements HttpRequestReader{
	private Scanner scanner;
	private Pattern CRLFPattern = Pattern.compile("\r\n");
	
	public InternalReader(InputStream in){
		scanner = new Scanner(in);
	}
	
	public String skipToNextNoneEmptyCRLFLine(){
		scanner.skip("\\s");
		return readCRLFLine();
	}
	
	public String readCRLFLine(){
		try{
			return  scanner.useDelimiter(CRLFPattern).next();
		} catch(NoSuchElementException e) {
			return null;
		}
	}
	
}
